<template>
	<view class="content">
		<view class="poster">
			<view v-if="type == 3">
				<view class="type2">
					<view class="left">
						<image :src="list[0].url" class="left_img" mode="aspectFill" @click="$goURl(list[0].link)"></image>
					</view>
					<view class="right">
						<view class="right1">
							<image :src="list[1]?list[1].url:''" class="right_img" mode="aspectFill" @click="$goURl(list[1].link)">
							</image>
						</view>
						<view class="right1">
							<image :src="list[2]?list[2].url:''" class="right_img" mode="aspectFill" @click="$goURl(list[2].link)">
							</image>
						</view>
					</view>
				</view>
			</view>
			<view v-if="type == 2">
				<view class="type2">
					<view class="right">
						<view class="right1">
							<image :src="list[0].url" class="right_img" mode="aspectFill" @click="$goURl(list[0].link)"></image>
						</view>
						<view class="right1">
							<image :src="list[1]?list[1].url:''" class="right_img" mode="aspectFill" @click="$goURl(list[1].link)">
							</image>
						</view>
					</view>
					<view class="left">
						<image :src="list[2]?list[2].url:''" class="left_img" mode="aspectFill" @click="$goURl(list[2].link)">
						</image>
					</view>
				</view>
			</view>
			<view v-if="type==1">
				<image :src="list[0].url" class="type1" mode="aspectFill" @click="gotosUrls(list[0])"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "poster",
		props: {
			type: {
				type: [String, Number],
				default: 2
			},
			list: {
				type: Array,
				default: () => []
			}
		},
		data() {
			return {

			};
		},
		created() {

		},
		methods: {
			gotosUrls(obj) {
				if (obj.link == '') {
					// #ifndef  MP-WEIXIN 
					uni.showToast({
						icon: 'none',
						title: '暂未开放'
					})
					return false;
					//  #endif 
				}
				var Tab = Tab = ['pages/index/index', '/pages/cat/cat', '/pages/personal/index', '/pages/goods/category']
				if (Tab.indexOf(obj.link) != -1) {
					uni.switchTab({
						url: obj.link
					})
					return
				}
				//暂时对外部链接不考虑
				//  else if (obj.link.indexOf("www") >= 0 || obj.link.indexOf("http") >= 0 || obj.link.indexOf("https") >= 0) {
				// 	uni.navigateTo({
				// 		url: `/pages/company/skip?url=${url}`             
				// 	})
				// }
				else {
					if (obj.goodsType == 0) {
						uni.navigateTo({
							url:`/pages/commodity/details?id=${obj.link}`
						})
					}
				}
			},
			toUrl(link) {
				let url = link
				var Tab = Tab = ['pages/index/index', '/pages/cat/cat', '/pages/personal/index']
				if (url == '' || url == '1') {
					// #ifndef  MP-WEIXIN 
					uni.showToast({
						icon:'none',
						title:'暂未开放'
					})
					return false;
					//  #endif 
				}
				if (Tab.indexOf(url) != -1) {
					uni.switchTab({
						url: url
					})
					return
				} else if (url.indexOf("www") >= 0 || url.indexOf("http") >= 0 || url.indexOf("https") >= 0) {
					uni.navigateTo({
						url: `/pages/company/skip?url=${url}`
					})
				} else {
					uni.navigateTo({
						url: url
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 20upx;
		background-color: #fff;
		border-radius: 20upx;
    box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.08);
	}
	.type1 {
		width: 100%;
		height: 272rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.type2 {
		width: 100%;
		display: flex;
		justify-content: space-between;

		.left {
			width: calc(50% - 10upx);
			height: 330rpx;

			.left_img {
				width: 100%;
				height: 330rpx;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
			}
		}

		.right {
			width: calc(50% - 10upx);
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.right_img {
				width: 100%;
				height: 156rpx;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
			}
		}

		.right1 {
				width: 100%;
			height: 156rpx;
		}
	}
</style>